DEW.DetailsController = function() {};

$.extend(DEW.DetailsController.prototype, {
    render: function() {
        DEW.ViewManager.removeAll();
        this.displayLayout();
        this.displayHeader();
        this.displayBody();
        this.displayFooter();
    },

    displayLayout: function() {
        var detailsLayout = new DEW.DetailsLayout();
        detailsLayout.render();
        $(detailsLayout.el).appendTo("#content");
        DEW.ViewManager.addView(detailsLayout);
    },

     displayHeader: function() {
        var header = new DEW.Header({
            logo: {
                src: 'images/logo.png',
                alt: 'Logo'
            },
            enlaces: [{
                    id:0,
                    text:'Home',
                    show:true,
                    textonly:false,
                    handler:function (){}
            },{
                    id:1,
                    text: 'Que es?',
                    show:true,
                    textonly: false,
                    handler:function(){} 
            },{
                    id: 2,
                    text: 'Apoya un Proyecto',
                    show:true,
                    textonly: false,
                 url: 'Create_project',
                },{
                id: 3,
                text: 'Iniciar Sesión',
                show: true,
                textonly: false,
                handler: function() {
                    var loginPopup = new DEW.PopupWindow({
                        ctClass: 'loginPopup',
                        title: 'Iniciar Sesión',
                        needValidation: false,
                        panel: new DEW.Login({
                            model: new DEW.LoginModel()
                        }),
                        buttons: [{
                            id: 'create-btn',
                            name : 'Ingresar',
                            hidden: false,
                            primary: true,
                            handler: function() {
                                loginPopup.panel.authenticate({
                                    success: function(email) {
                                        loginPopup.panel.hideLoginError();
                                        header.login(email);
                                        loginPopup.close();
                                    }
                                });
                            }
                        }]
                    });
                    loginPopup.render();
                    $("body").append(loginPopup.el);
                }
            },{
                id: 4,
                text: '',
                textonly: true,
                show: false
            },{
                id: 5,
                text: 'Salir',
                show: false,
                textonly: false,
                handler: function() {
                    header.logout();
                }
            },{
                id:6,
                text: 'Registro',
                show: true,
                textonly: false,
                handler: function(){
                    var Registro = new DEW.PopupUser({
                        ctClass: 'Registro',
                        title: 'Registro',
                        needValidation: false,
                        panel: new DEW.RegistroUser({
                       
                        }),
                        buttons:[{
                              id: 'create-btn',
                            name : 'Registrar',
                            hidden: false,
                            primary: true,
                            handler:function(){

                            }
                        }]
                    });
                    Registro.render();
                    $("body").append(Registro.el);
                }
            },{
                id: 7,
                text: '',
                textonly: true,
                show: false
            },{
                id: 8,
                text: 'Salir',
                show: false,
                textonly: false,
                handler: function() {
                    header.logout();
                }
            }]
        });
        header.render();
        $(header.el).appendTo("#header");
    },

    displayBody: function() {
        var createproject =  new DEW.Create_project();
        createproject.render();
        $(createproject.el).appendTo("#body");
        DEW.ViewManager.addView(itemView);
    },

    displayFooter: function() {
        var footer = new DEW.Footer();
        footer.render();
        $(footer.el).appendTo("#footer");
    }

});